# -*- mode: makefile -*-

NAME = `cat NAME`

prepare:	## Prepare source tree for compilation
	@./scripts/src_prepare

rename:	## Make combined english+russian pdf file
	-[[ -f default.pdf ]] && mv default.pdf $(NAME).pdf
	-[ -f russian.pdf -a -f english.pdf ] && pdftk english.pdf russian.pdf cat output $(NAME).pdf

cite:	## Generate '.bib' file
	-[[ -f default.aux ]] && jabref -n -a default,cite.bib ~/work/bib/bib/main.bib
	-[[ -f russian.aux ]] && jabref -n -a russian,cite.russian.bib ~/work/bib/bib/main.bib ; cat cite.russian.bib >> cite.bib
	-[[ -f english.aux ]] && jabref -n -a english,cite.english.bib ~/work/bib/bib/main.bib ; cat cite.english.bib >> cite.bib
	# -[[ -f default.aux ]] && bibexport -r ~/work/bib/bib/main.bib -o cite.default.bib default ; cat cite.default.bib >> cite.bib
	# -[[ -f russian.aux ]] && bibexport -r ~/work/bib/bib/main.bib -o cite.russian.bib russian ; cat cite.russian.bib >> cite.bib
	# -[[ -f english.aux ]] && bibexport -r ~/work/bib/bib/main.bib -o cite.english.bib english ; cat cite.english.bib >> cite.bib
	-[[ -f cite.bib ]] && bibtex-tidy --no-escape --duplicates key --merge cite.bib

### Template targets:

vestnik:
	scripts/prepare_vestnik $(NAME) title/*.tex text/*.tex

casc:
	scripts/prepare_casc $(NAME) text/*.tex

mmcp:
	scripts/prepare_mmcp $(NAME) text/*.tex

mmg:
	scripts/prepare_mmg $(NAME) text/*.tex

ecms:
	scripts/prepare_ecms $(NAME) text/*.tex

aisc:
	scripts/prepare_aisc $(NAME) text/*.tex

jpcs:
	scripts/prepare_jpcs $(NAME) text/*.tex

lncs:	### Use template: Lecture Notes in Computer Science (LNCS)
	scripts/prepare lncs $(NAME) title/*.tex text/*.tex

spie:	### Use template: SPIE
	scripts/prepare spie $(NAME) title/*.tex text/*.tex

iopconf:	### Use template: IOPconf
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

svproc:		### Use template: SVProc
	scripts/prepare_svproc $(NAME) title/*.tex text/*.tex

ieeetran:	### Use template: IEEEtran
	scripts/prepare_ieeetran $(NAME) title/*.tex text/*.tex

webofc:		### Use template: WebOFC
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

programm:	### Use template: Программирование
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

elsarticle:	### Use template: Elsiever article
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

sn-jnl:	### Use template: Springer Nature article
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

arxiv:		### Use template: arXiv
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

vychmat:		### Use template: Журнал вычислительной математики и математической физики
	scripts/prepare $@ $(NAME) title/*.tex text/*.tex

